//
//  MyYunPlaVC.m
//  reSearchDemo
//
//  Created by 云库 on 15/7/20.
//  Copyright (c) 2015年 Kiwaro. All rights reserved.
//

#import "MyYunPlaVC.h"
#import "MenuView.h"
#import "LoginYunPlaVC.h"
#import "RegisterYunPlaVC.h"
#import "RegViewController.h"
#import "RegisterViewController.h"
@interface MyYunPlaVC (){
    UIView  * actionBar;
}
@property(nonatomic,retain)MenuView * menuView;
@end

@implementation MyYunPlaVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    [[HTTPGlobals shareHTTPGlobal] PostHTTPRequest:@"MobilePort/index/platformList.html" parameters:nil finish:^(BOOL seccess, NSString *error, id obj) {
        if (seccess) {
            
            DLog(@"obj = %@",obj);
            DLog(@"info = %@",obj[@"info"]);
        }else {
            DLog(@"卧槽又失败了,什么鬼接口!");
        }
    }];

    
    
    
    // Do any additional setup after loading the view.
    self.title = @"我的云平台";
    self.view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [self setRightBarButtonImage:LOADIMAGE(@"btn_more") highlightedImage:nil selector:@selector(menuAction)];
    
//    UIView * actionbar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, 44)];
//    self.navigationItem.titleView = actionbar;
//    UILabel * lab=[[UILabel alloc]initWithFrame:CGRectMake(8, 0, 100, 40)];
//    lab.text=@"我的云平台";
//    lab.font=[UIFont systemFontOfSize:20];
//    lab.textColor=[UIColor whiteColor];
//    [actionbar addSubview:lab];
    [self buildMainView];
    
    UIBarButtonItem *back = [[UIBarButtonItem alloc] init];
    back.title = @"";
    self.navigationItem.backBarButtonItem = back;
    
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    [manager GET:@"http://yun.imyunku.com/yunku/index.php/MobilePort/index/platformList.html" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        
        DLog(@"%@",dict);
        
        
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        DLog(@"下载失败");
    }];



    
}
-(void)buildMainView{
    NSArray * arr=@[@"亲，你还没有开通云平台",@"打开你的心扉",@"亲密我的平台",@"点击右上角注册吧",@"更多平台助手帮助你",];
    for (int i=0; i<5; i++) {
        UILabel * lab=[[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-100, 60+64+i*50, 240, 40)];
        lab.textColor=[UIColor grayColor];
        lab.font=[UIFont systemFontOfSize:20];
        lab.text=[NSString stringWithFormat:@"%@",arr[i]];
        [self.view addSubview:lab];
    }
}
-(void)menuAction{
    NSArray * arr = nil;
    //    if ([share.uid isEqualToString:[BSEngine currentUserId]]) {
    //        arr = @[@"发送给朋友", @"保存到手机", @"收藏", @"删除"];
    //    } else {
    arr = @[@"登陆云平台", @"注册云平台"];
    //    }
    _menuView = [[MenuView alloc] initWithButtonTitles:arr withDelegate:self];
    _menuView.hasImage = NO;
    [_menuView showInView:self.view origin:CGPointMake(self.view.width - 180, 70)];
    _menuView.buttonView.delegate=self;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [_menuView hide];
    if (indexPath.row) {
        [self pushViewController:[RegisterYunPlaVC new]];
//        [self pushViewController:[RegisterViewController new]];
        
    }else{
        LoginYunPlaVC * vc=[[LoginYunPlaVC alloc]init];
        [self pushViewController:vc];
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
